function [dist,t] = scs_II_transform(dt,dur,scale)
%
% [dist,t] = scs_transform(dt,duration,scale)
% 
% Return the distribution for a shorter duration "dur" in hours and 
% the corresponding time series based on scs type II 24-hr storm
% 
% Series is generated using a cubic spline interpolation
%

if nargin == 2
    scale = 1;
end

% Store distribution for 24-hr storm
rain_dist = [0.000000 0.001010 0.002020 0.003050 0.004080 0.005130 0.006180 0.007250 0.008320 0.009410 0.010500 0.011610 0.012720 0.013850 0.014980 0.016130 0.017280 0.018450 0.019620 0.020810 0.022000 0.023210 0.024420 0.025650 0.026880 0.028130 0.029380 0.030650 0.031920 0.033210 0.034500 0.035810 0.037120 0.038450 0.039780 0.041130 0.042480 0.043850 0.045220 0.046610 0.048000 0.049410 0.050840 0.052290 0.053760 0.055250 0.056760 0.058290 0.059840 0.061410 0.063000 0.064610 0.066240 0.067890 0.069560 0.071250 0.072960 0.074690 0.076440 0.078210 0.080000 0.081810 0.083640 0.085490 0.087360 0.089250 0.091160 0.093090 0.095040 0.097010 0.099000 0.101010 0.103040 0.105090 0.107160 0.109250 0.111360 0.113490 0.115640 0.117810 0.120000 0.122250 0.124600 0.127050 0.129600 0.132250 0.135000 0.137850 0.140800 0.143850 0.147000 0.150200 0.153400 0.156600 0.159800 0.163000 0.166280 0.169720 0.173320 0.177080 0.181000 0.185120 0.189480 0.194080 0.198920 0.204000 0.209400 0.215200 0.221400 0.228000 0.235000 0.242680 0.251320 0.260920 0.271480 0.283000 0.306840 0.354360 0.430790 0.567860 0.663000 0.681960 0.698640 0.713040 0.725160 0.735000 0.743440 0.751360 0.758760 0.765640 0.772000 0.777960 0.783640 0.789040 0.794160 0.799000 0.803600 0.808000 0.812200 0.816200 0.820000 0.823670 0.827260 0.830790 0.834240 0.837630 0.840940 0.844190 0.847360 0.850470 0.853500 0.856470 0.859360 0.862190 0.864940 0.867630 0.870240 0.872790 0.875260 0.877670 0.880000 0.882290 0.884550 0.886790 0.889000 0.891190 0.893350 0.895490 0.897600 0.899690 0.901750 0.903790 0.905800 0.907790 0.909750 0.911690 0.913600 0.915490 0.917350 0.919190 0.921000 0.922790 0.924550 0.926290 0.928000 0.929690 0.931350 0.932990 0.934600 0.936190 0.937750 0.939290 0.940800 0.942290 0.943750 0.945190 0.946600 0.947990 0.949350 0.950690 0.952000 0.953300 0.954590 0.955880 0.957160 0.958440 0.959710 0.960980 0.962240 0.963500 0.964750 0.966000 0.967240 0.968480 0.969710 0.970940 0.972160 0.973380 0.974590 0.975800 0.977000 0.978200 0.979390 0.980580 0.981760 0.982940 0.984110 0.985280 0.986440 0.987600 0.988750 0.989900 0.991040 0.992180 0.993310 0.994440 0.995560 0.996680 0.997790 0.998900 1.000000];
t_rain_dist = 0:.1:24;

% Generate a centered time series and interpolate
t_rain_transform = (12-dur/2):dt:(12+dur/2);
rain_transform = interp1(t_rain_dist, rain_dist, t_rain_transform, 'pchip');
rain_transform = rain_transform - rain_transform(1);
rain_transform = rain_transform./rain_transform(end);

% Remove the offset on the time series and assign the output variables
t = t_rain_transform-t_rain_transform(1);
dist = rain_transform * scale;
